package com.dhq.activemq;

import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;

//@Component
public class QueueConsumer {

    /**
     * @Author zhangxiaofeng
     * @Description //TODO
     * @Date  2019/5/23 18:33
     * @Param [message]
     * @return
     **/
//    @JmsListener(destination = "activemqQueue")
    @JmsListener(destination = "${spring.activemq.queue-name}")
    public void receiveQueue(Message message){
        try {
            MapMessage mapMessage =(MapMessage) message;
            //接受字符串类型
            String info = mapMessage.getString("info");
            System.out.println(info);
            //接受对象类型
            /*byte[] actives =(byte[]) mapMessage.getObject("active");
            Active active = (Active) SerializeUtil.deserialize(actives);
            System.out.println(active);
            System.out.println("ID>>>"+active.getAcId()+"     NAME>>>"+active.getAcName()+"     AGE>>>"+active.getAcAge());*/
        } catch (JMSException e) {
            e.printStackTrace();
        }

    }

}
